package com.javaee.request;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * <li>转发前的Servlet
 * <li>直接从一个Servlet转发数据到另一个Servlet
 * <li>使用request对象，也就是作用域对象
 * <li>从结果可以看出，客户端不知道有多少个Servlet参与了这次控制转发过程
 * 
 * @author fhzheng
 *
 */
public class RequestForwardServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		request.setAttribute("username", "周星星");
		RequestDispatcher dispatcher = request.getRequestDispatcher("/ResultServlet");
		dispatcher.forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
